import cv2 as cv
import numpy as np
import matplotlib.pyplot as plt

img = cv.imread("assets/cb.jpg")

plt.figure(figsize=(10,10))
plt.subplot(321)
plt.imshow(cv.cvtColor(img, cv.COLOR_BGR2RGB))

x = cv.Sobel(img, cv.CV_16S, 1, 0)
#y = cv.Sobel(img, cv.CV_16S, 0, 1)

x = cv.convertScaleAbs(x)
#y = cv.convertScaleAbs(y)

img_sobel = cv.addWeighted(x, 0.5, x, 0.5, 0)

plt.subplot(322)
plt.imshow(cv.cvtColor(img_sobel, cv.COLOR_BGR2RGB))

img_blur = cv.GaussianBlur(img, (5,5), 1, 1)
plt.subplot(323)
plt.imshow(cv.cvtColor(img_blur, cv.COLOR_BGR2RGB))

img_laplacian = cv.Laplacian(img_blur, -1, 5, 3, 8)
print(img_laplacian)

plt.subplot(324)
plt.imshow(cv.cvtColor(img_laplacian, cv.COLOR_BGR2RGB))

kernel_lap = np.array([[0, 0, 1, 0, 0],
                       [0, 1, 2, 1, 0],
                       [1, 2, -16, 2, 1],
                       [0, 1, 2, 1, 0],
                       [0, 0, 1, 0, 0]])

img_lap = cv.filter2D(img,-1,kernel_lap)
plt.subplot(325)
plt.imshow(cv.cvtColor(img_lap, cv.COLOR_BGR2RGB))
plt.show()
